package com.ruoyi.web.controller.fx;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.fx.FxTimeQuantum;
import com.ruoyi.system.service.fx.IFxTimeQuantumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 预约时间段Controller
 *
 * @author ruoyi
 * @date 2025-04-30
 */
@RestController
@RequestMapping("/system/quantum")
public class FxTimeQuantumController extends BaseController
{
    @Autowired
    private IFxTimeQuantumService fxTimeQuantumService;

    /**
     * 查询预约时间段列表
     */
    @GetMapping("/list")
    public TableDataInfo list(FxTimeQuantum fxTimeQuantum)
    {
        startPage();
        List<FxTimeQuantum> list = fxTimeQuantumService.selectFxTimeQuantumList(fxTimeQuantum);
        return getDataTable(list);
    }

    /**
     * 导出预约时间段列表
     */
    @Log(title = "预约时间段", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FxTimeQuantum fxTimeQuantum)
    {
        List<FxTimeQuantum> list = fxTimeQuantumService.selectFxTimeQuantumList(fxTimeQuantum);
        ExcelUtil<FxTimeQuantum> util = new ExcelUtil<FxTimeQuantum>(FxTimeQuantum.class);
        util.exportExcel(response, list, "预约时间段数据");
    }

    /**
     * 获取预约时间段详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fxTimeQuantumService.selectFxTimeQuantumById(id));
    }

    /**
     * 新增预约时间段
     */
    @Log(title = "预约时间段", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FxTimeQuantum fxTimeQuantum)
    {
        return toAjax(fxTimeQuantumService.insertFxTimeQuantum(fxTimeQuantum));
    }

    /**
     * 修改预约时间段
     */
    @Log(title = "预约时间段", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FxTimeQuantum fxTimeQuantum)
    {
        return toAjax(fxTimeQuantumService.updateFxTimeQuantum(fxTimeQuantum));
    }

    /**
     * 删除预约时间段
     */
    @Log(title = "预约时间段", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fxTimeQuantumService.deleteFxTimeQuantumByIds(ids));
    }
}
